//
//  HamatonTyreDisplayViewController.swift
//  hamaton-app
//
//  Created by intyt on 2024/4/26.
// 车辆轮胎胎温胎压展示

import UIKit
import CoreBluetooth
import SnapKit
import Toast_Swift


class HamatonTyreDisplayViewController: HamatonBaseViewController {
    var carType: String = "0"
    var tyrePositionData: Data = Data() // 轮胎位置
    //weak var delegate: HamatonTyreDisplayDelegate?
    // 所有轮胎信息
    var allBindTyreData: [Data] = []
    
    // 车辆轮胎传感器绑定
    var TyreTmpsInfoModel: Data? {
        didSet {
            let tyreNum = String(format: "%02X", TyreTmpsInfoModel![1])
            var temp  = Int(String(format: "%02X", TyreTmpsInfoModel![6]), radix: 16)
            if let tempNum = Int(String(format: "%02X", TyreTmpsInfoModel![6]), radix: 16) {
                if tempNum > 0 {
                    temp = tempNum - 40
                }
            }
            let pressure = Int(String(format: "%02X", TyreTmpsInfoModel![3]) + String(format: "%02X", TyreTmpsInfoModel![2]), radix: 16)
            let type = String(format: "%02X", TyreTmpsInfoModel![4]) + String(format: "%02X", TyreTmpsInfoModel![5])
            let color = TyreStatusOption[String(type)] ?? Theme.Color.Background.tyregray
            if tyreNum == "16" {
                tyreBtn16.backgroundColor = color
                tyreBtn16Temp.text = String(temp!) + "°C"
                tyreBtn16Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "17" {
                tyreBtn17.backgroundColor = color
                tyreBtn17Temp.text = String(temp!) + "°C"
                tyreBtn17Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "19" {
                tyreBtn19.backgroundColor = color
                tyreBtn19Temp.text = String(temp!) + "°C"
                tyreBtn19Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "1A" {
                tyreBtn1a.backgroundColor = color
                tyreBtn1aTemp.text = String(temp!) + "°C"
                tyreBtn1aPressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "26" {
                tyreBtn26.backgroundColor = color
                tyreBtn26Temp.text = String(temp!) + "°C"
                tyreBtn26Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "27" {
                tyreBtn27.backgroundColor = color
                tyreBtn27Temp.text = String(temp!) + "°C"
                tyreBtn27Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "29" {
                tyreBtn29.backgroundColor = color
                tyreBtn29Temp.text = String(temp!) + "°C"
                tyreBtn29Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "2A" {
                tyreBtn2a.backgroundColor = color
                tyreBtn2aTemp.text = String(temp!) + "°C"
                tyreBtn2aPressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "36" {
                tyreBtn36.backgroundColor = color
                tyreBtn36Temp.text = String(temp!) + "°C"
                tyreBtn36Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "37" {
                tyreBtn37.backgroundColor = color
                tyreBtn37Temp.text = String(temp!) + "°C"
                tyreBtn37Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "39" {
                tyreBtn39.backgroundColor = color
                tyreBtn39Temp.text = String(temp!) + "°C"
                tyreBtn39Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "3A" {
                tyreBtn3a.backgroundColor = color
                tyreBtn3aTemp.text = String(temp!) + "°C"
                tyreBtn3aPressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "46" {
                tyreBtn46.backgroundColor = color
                tyreBtn46Temp.text = String(temp!) + "°C"
                tyreBtn46Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "47" {
                tyreBtn47.backgroundColor = color
                tyreBtn47Temp.text = String(temp!) + "°C"
                tyreBtn47Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "49" {
                tyreBtn49.backgroundColor = color
                tyreBtn49Temp.text = String(temp!) + "°C"
                tyreBtn49Pressure.text = String(pressure!) + "kPa"
            } else if tyreNum == "4A" {
                tyreBtn4a.backgroundColor = color
                tyreBtn4aTemp.text = String(temp!) + "°C"
                tyreBtn4aPressure.text = String(pressure!) + "kPa"
            }
        }
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .clear
        navigationItem.title = "轮胎参数展示"
        let margTop: Float = 15
        let margBottom: Float = 115
        let margRight: Float = -20
        let margLeft: Float = 20
        let labelTop: Float = 12
        let labelBottom: Float = -12
        let labelLeft: Float = 0
        let labelWidth: Float = 50
        let labelHeight: Float = 32
        // 不同类型的颜色与说明文字
        view.addSubview(type1Btn)
        view.addSubview(type1Label)
        view.addSubview(type2Btn)
        view.addSubview(type2Label)
        view.addSubview(type3Btn)
        view.addSubview(type3Label)
        view.addSubview(type4Btn)
        view.addSubview(type4Label)
        
        view.addSubview(centerLine) // 中心线
        view.addSubview(tyreBtn17) // 一轴左内胎
        view.addSubview(tyreBtn17Temp)
        view.addSubview(tyreBtn17Pressure)
        view.addSubview(tyreBtn16) // 一轴左外胎
        view.addSubview(tyreBtn16Temp)
        view.addSubview(tyreBtn16Pressure)
        view.addSubview(tyreBtn19) // 一轴右内胎
        view.addSubview(tyreBtn19Temp)
        view.addSubview(tyreBtn19Pressure)
        view.addSubview(tyreBtn1a) // 一轴右外胎
        view.addSubview(tyreBtn1aTemp)
        view.addSubview(tyreBtn1aPressure)
        view.addSubview(tyreBtn27) // 二轴左内胎
        view.addSubview(tyreBtn27Temp)
        view.addSubview(tyreBtn27Pressure)
        view.addSubview(tyreBtn26) // 二轴左外胎
        view.addSubview(tyreBtn26Temp)
        view.addSubview(tyreBtn26Pressure)
        view.addSubview(tyreBtn29) // 二轴右内胎
        view.addSubview(tyreBtn29Temp)
        view.addSubview(tyreBtn29Pressure)
        view.addSubview(tyreBtn2a) // 二轴右外胎
        view.addSubview(tyreBtn2aTemp)
        view.addSubview(tyreBtn2aPressure)
        view.addSubview(tyreBtn37) // 三轴左内胎
        view.addSubview(tyreBtn37Temp)
        view.addSubview(tyreBtn37Pressure)
        view.addSubview(tyreBtn36) // 三轴左外胎
        view.addSubview(tyreBtn36Temp)
        view.addSubview(tyreBtn36Pressure)
        view.addSubview(tyreBtn39) // 三轴右内胎
        view.addSubview(tyreBtn39Temp)
        view.addSubview(tyreBtn39Pressure)
        view.addSubview(tyreBtn3a) // 三轴右外胎
        view.addSubview(tyreBtn3aTemp)
        view.addSubview(tyreBtn3aPressure)
        view.addSubview(tyreBtn47) // 四轴左内胎
        view.addSubview(tyreBtn47Temp)
        view.addSubview(tyreBtn47Pressure)
        view.addSubview(tyreBtn46) // 四轴左外胎
        view.addSubview(tyreBtn46Temp)
        view.addSubview(tyreBtn46Pressure)
        view.addSubview(tyreBtn49) // 四轴右内胎
        view.addSubview(tyreBtn49Temp)
        view.addSubview(tyreBtn49Pressure)
        view.addSubview(tyreBtn4a) // 四轴右外胎
        view.addSubview(tyreBtn4aTemp)
        view.addSubview(tyreBtn4aPressure)
//
        if carType == "0" {
            tyreBtn16.isHidden = true
            tyreBtn1a.isHidden = true
        }
        getAllInfo()
        // 不同类型颜色
        type1Btn.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(margTop)
            make.left.equalToSuperview().offset(margLeft*3)
            make.width.equalTo(15)
            make.height.equalTo(15)
        }
        type1Label.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(margTop)
            make.left.equalTo(type1Btn.snp.right).offset(margLeft)
            make.width.equalTo(200)
            make.height.equalTo(15)
        }
        type2Btn.snp.makeConstraints { make in
            make.top.equalTo(type1Btn.snp.bottom).offset(margTop)
            make.left.equalToSuperview().offset(margLeft*3)
            make.width.equalTo(15)
            make.height.equalTo(15)
        }
        type2Label.snp.makeConstraints { make in
            make.top.equalTo(type1Btn.snp.bottom).offset(margTop)
            make.left.equalTo(type2Btn.snp.right).offset(margLeft)
            make.width.equalTo(200)
            make.height.equalTo(15)
        }
        type3Btn.snp.makeConstraints { make in
            make.top.equalTo(type2Btn.snp.bottom).offset(margTop)
            make.left.equalToSuperview().offset(margLeft*3)
            make.width.equalTo(15)
            make.height.equalTo(15)
        }
        type3Label.snp.makeConstraints { make in
            make.top.equalTo(type2Btn.snp.bottom).offset(margTop)
            make.left.equalTo(type3Btn.snp.right).offset(margLeft)
            make.width.equalTo(200)
            make.height.equalTo(15)
        }
        type4Btn.snp.makeConstraints { make in
            make.top.equalTo(type3Btn.snp.bottom).offset(margTop)
            make.left.equalToSuperview().offset(margLeft*3)
            make.width.equalTo(15)
            make.height.equalTo(15)
        }
        type4Label.snp.makeConstraints { make in
            make.top.equalTo(type3Btn.snp.bottom).offset(margTop)
            make.left.equalTo(type4Btn.snp.right).offset(margLeft)
            make.width.equalTo(200)
            make.height.equalTo(15)
        }
        
        // 中心线
        centerLine.snp.makeConstraints { make in
            make.top.equalTo(type4Btn.snp.bottom).offset(margTop)
            // x轴居中对齐
            make.centerX.equalToSuperview()
            make.width.equalTo(1)
            make.height.equalTo(560)
        }
        // 一轴左内胎
        tyreBtn17.snp.makeConstraints { make in
            make.top.equalTo(type4Btn.snp.bottom).offset(margTop*4)
            make.right.equalTo(centerLine.snp.left).offset(margRight*2)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn17Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn17.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn17.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn17Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn17.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn17.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 一轴左外胎
        tyreBtn16.snp.makeConstraints { make in
            make.top.equalTo(type4Btn.snp.bottom).offset(margTop*4)
            make.right.equalTo(tyreBtn17.snp.left).offset(margRight)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn16Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn16.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn16.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn16Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn16.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn16.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 一轴右内胎
        tyreBtn19.snp.makeConstraints { make in
            make.top.equalTo(type4Btn.snp.bottom).offset(margTop*4)
            make.left.equalTo(centerLine.snp.right).offset(margLeft*2)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn19Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn19.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn19.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn19Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn19.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn19.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 一轴右外胎
        tyreBtn1a.snp.makeConstraints { make in
            make.top.equalTo(type4Btn.snp.bottom).offset(margTop*4)
            make.left.equalTo(tyreBtn19.snp.right).offset(margLeft)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn1aTemp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn1a.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn1a.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn1aPressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn1a.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn1a.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 二轴左内胎
        tyreBtn27.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn17.snp.bottom).offset(margTop)
            make.right.equalTo(centerLine.snp.left).offset(margRight*2)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn27Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn27.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn27.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn27Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn27.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn27.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 二轴左外胎
        tyreBtn26.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn16.snp.bottom).offset(margTop)
            make.right.equalTo(tyreBtn17.snp.left).offset(margRight)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn26Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn26.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn26.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn26Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn26.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn26.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 二轴右内胎
        tyreBtn29.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn19.snp.bottom).offset(margTop)
            make.left.equalTo(centerLine.snp.right).offset(margLeft*2)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn29Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn29.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn29.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn29Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn29.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn29.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 二轴右外胎
        tyreBtn2a.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn1a.snp.bottom).offset(margTop)
            make.left.equalTo(tyreBtn19.snp.right).offset(margLeft)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn2aTemp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn2a.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn2a.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn2aPressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn2a.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn2a.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 三轴左内胎
        tyreBtn37.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn27.snp.bottom).offset(margTop)
            make.right.equalTo(centerLine.snp.left).offset(margRight*2)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn37Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn37.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn37.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn37Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn37.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn37.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 三轴左外胎
        tyreBtn36.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn26.snp.bottom).offset(margTop)
            make.right.equalTo(tyreBtn27.snp.left).offset(margRight)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn36Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn36.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn36.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn36Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn36.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn36.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 三轴右内胎
        tyreBtn39.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn29.snp.bottom).offset(margTop)
            make.left.equalTo(centerLine.snp.right).offset(margLeft*2)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn39Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn39.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn39.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn39Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn39.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn39.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 三轴右外胎
        tyreBtn3a.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn2a.snp.bottom).offset(margTop)
            make.left.equalTo(tyreBtn29.snp.right).offset(margLeft)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn3aTemp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn3a.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn3a.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn3aPressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn3a.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn3a.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 四轴左内胎
        tyreBtn47.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn37.snp.bottom).offset(margTop)
            make.right.equalTo(centerLine.snp.left).offset(margRight*2)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn47Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn47.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn47.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn47Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn47.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn47.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 四轴左外胎
        tyreBtn46.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn36.snp.bottom).offset(margTop)
            make.right.equalTo(tyreBtn37.snp.left).offset(margRight)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn46Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn46.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn46.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn46Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn46.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn46.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 四轴右内胎
        tyreBtn49.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn39.snp.bottom).offset(margTop)
            make.left.equalTo(centerLine.snp.right).offset(margLeft*2)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn49Temp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn49.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn49.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn49Pressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn49.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn49.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        // 四轴右外胎
        tyreBtn4a.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn3a.snp.bottom).offset(margTop)
            make.left.equalTo(tyreBtn39.snp.right).offset(margLeft)
            make.width.equalTo(50)
            make.height.equalTo(100)
        }
        tyreBtn4aTemp.snp.makeConstraints { make in
            make.top.equalTo(tyreBtn4a.snp.top).offset(labelTop)
            make.left.equalTo(tyreBtn4a.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }
        tyreBtn4aPressure.snp.makeConstraints { make in
            make.bottom.equalTo(tyreBtn4a.snp.bottom).offset(labelBottom)
            make.left.equalTo(tyreBtn4a.snp.left).offset(labelLeft)
            make.width.equalTo(labelWidth)
            make.height.equalTo(labelHeight)
        }

    }
    
    
    // 中心线
    lazy var centerLine: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 一轴左外胎：轮胎1，6
    lazy var tyreBtn16: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn16Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn16Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 一轴左内胎：轮胎1，7
    lazy var tyreBtn17: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn17Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn17Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    
    // 一轴右内胎：轮胎1，9
    lazy var tyreBtn19: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn19Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn19Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 一轴右外胎：轮胎1，a
    lazy var tyreBtn1a: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn1aTemp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn1aPressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 二轴左外胎：轮胎2，6
    lazy var tyreBtn26: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn26Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn26Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 二轴左内胎：轮胎2，7
    lazy var tyreBtn27: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn27Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn27Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 二轴右内胎：轮胎2，9
    lazy var tyreBtn29: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn29Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn29Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 二轴右外胎：轮胎2，a
    lazy var tyreBtn2a: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn2aTemp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn2aPressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 三轴左外胎：轮胎3，6
    lazy var tyreBtn36: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn36Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn36Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 三轴左内胎：轮胎3，7
    lazy var tyreBtn37: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn37Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn37Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 三轴右内胎：轮胎3，9
    lazy var tyreBtn39: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn39Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn39Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 三轴右外胎：轮胎3，a
    lazy var tyreBtn3a: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn3aTemp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn3aPressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 四轴左外胎：轮胎4，6
    lazy var tyreBtn46: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn46Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn46Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 四轴左内胎：轮胎4，7
    lazy var tyreBtn47: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn47Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn47Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 四轴右内胎：轮胎4，9
    lazy var tyreBtn49: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn49Temp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn49Pressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 四轴右外胎：轮胎4，a
    lazy var tyreBtn4a: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = Theme.Color.Background.tyregray
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 5
        return button
    }()
    // 温度
    lazy var tyreBtn4aTemp: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    // 压强
    lazy var tyreBtn4aPressure: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0xFFFFFF)
        label.font = Theme.Font.size(12)
        label.text = ""
        label.backgroundColor = .clear
        label.textAlignment = .center
        return label
    }()
    
    // 类型1——绿色正常
    lazy var type1Btn: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = .green
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 10
        return button
    }()
    lazy var type1Label: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0x333333)
        label.font = Theme.Font.size(14)
        label.text = "正常"
        label.backgroundColor = .clear
        label.textAlignment = .left
        return label
    }()
    // 类型2——红色胎温胎压异常
    lazy var type2Btn: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = UIColor(hex6: 0xFF0000)
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 10
        return button
    }()
    lazy var type2Label: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6:0x333333)
        label.font = Theme.Font.size(14)
        label.text = "胎温胎压异常"
        label.backgroundColor = .clear
        label.textAlignment = .left
        return label
    }()
    // 类型3——粉色传感器电量低
    lazy var type3Btn: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = UIColor(hex6: 0xFF69B4)
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 10
        return button
    }()
    lazy var type3Label: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6: 0x333333)
        label.font = Theme.Font.size(14)
        label.text = "传感器电量低"
        label.backgroundColor = .clear
        label.textAlignment = .left
        return label
    }()
    // 类型4——紫色传感器信号异常
    lazy var type4Btn: UIButton = {
        let button = UIButton(type: .custom)
        button.setTitleColor(UIColor(hex6: 0xFFFFFF, alpha: 1.0), for: .normal)
        button.titleLabel!.font = Theme.Font.size(16, bold: true)
        button.backgroundColor  = UIColor(hex6: 0x9400D3)
        button.layer.masksToBounds = true
        button.layer.cornerRadius = 10
        return button
    }()
    lazy var type4Label: UILabel = {
        let label = UILabel()
        label.textColor = UIColor(hex6: 0x333333)
        label.font = Theme.Font.size(14)
        label.text = "传感器信号异常"
        label.backgroundColor = .clear
        label.textAlignment = .left
        return label
    }()
    
    // 轮胎参数展示
    func getAllInfo() {
        print(allBindTyreData)
        for (index, item) in allBindTyreData.enumerated() {
            self.TyreTmpsInfoModel = item
        }
    }
    // 字符串前两位与后两位位置对调
    func swapFirstAndLastTwo(_ str: String) -> String {
        // 确保字符串长度至少为 2，否则不需要交换
        guard str.count >= 2 else {
            return str
        }
        // 将字符串拆分为前两位和后面的部分
        let startIndex = str.startIndex
        let endIndex = str.index(startIndex, offsetBy: 2)
        let firstTwo = str[startIndex..<endIndex]
        let remaining = str[endIndex...]
        
        // 将前两位和后两位交换位置后拼接起来
        return "\(remaining)\(firstTwo)"
    }
    // 轮胎全部隐藏
    func hiddenAllInfo() {
        tyreBtn16.isHidden = true
        tyreBtn16Temp.isHidden = true
        tyreBtn16Pressure.isHidden = true
        tyreBtn17.isHidden = true
        tyreBtn17Temp.isHidden = true
        tyreBtn17Pressure.isHidden = true
        tyreBtn19.isHidden = true
        tyreBtn19Temp.isHidden = true
        tyreBtn19Pressure.isHidden = true
        tyreBtn1a.isHidden = true
        tyreBtn1aTemp.isHidden = true
        tyreBtn1aPressure.isHidden = true
        tyreBtn26.isHidden = true
        tyreBtn26Temp.isHidden = true
        tyreBtn26Pressure.isHidden = true
        tyreBtn27.isHidden = true
        tyreBtn27Temp.isHidden = true
        tyreBtn27Pressure.isHidden = true
        tyreBtn29.isHidden = true
        tyreBtn29Temp.isHidden = true
        tyreBtn29Pressure.isHidden = true
        tyreBtn2a.isHidden = true
        tyreBtn2aTemp.isHidden = true
        tyreBtn2aPressure.isHidden = true
        tyreBtn36.isHidden = true
        tyreBtn36Temp.isHidden = true
        tyreBtn36Pressure.isHidden = true
        tyreBtn37.isHidden = true
        tyreBtn37Temp.isHidden = true
        tyreBtn37Pressure.isHidden = true
        tyreBtn39.isHidden = true
        tyreBtn39Temp.isHidden = true
        tyreBtn39Pressure.isHidden = true
        tyreBtn3a.isHidden = true
        tyreBtn3aTemp.isHidden = true
        tyreBtn3aPressure.isHidden = true
        tyreBtn46.isHidden = true
        tyreBtn46Temp.isHidden = true
        tyreBtn46Pressure.isHidden = true
        tyreBtn47.isHidden = true
        tyreBtn47Temp.isHidden = true
        tyreBtn47Pressure.isHidden = true
        tyreBtn49.isHidden = true
        tyreBtn49Temp.isHidden = true
        tyreBtn49Pressure.isHidden = true
        tyreBtn4a.isHidden = true
        tyreBtn4aTemp.isHidden = true
        tyreBtn4aPressure.isHidden = true
       // getAllTyreInfo()
    }
    // 获取所有轮胎信息
    func getAllTyreInfo() {
        let count = Int(tyrePositionData.count)
        var tyreArray = [String]()
        for index in 1..<count {
            tyreArray.append(String(format: "%02X", tyrePositionData[index]))
        }
        // 创建一个 DispatchQueue 用于执行循环任务
        let dispatchQueue = DispatchQueue.global()
        for (index, item) in tyreArray.enumerated() {
            // 在每次循环之前等待 300 毫秒
            let delayTime = DispatchTime.now() + .milliseconds(index * 300)
            dispatchQueue.asyncAfter(deadline: delayTime) {
               // self.delegate?.getTyreSensor(item)
            }
        }
    }
}
